<template>

    <div class="app-container" v-if="canList">
        <div class="filter-container">
            <el-input @keyup.enter.native="handleFilter" class="filter-item input" placeholder="订单号"
                      style="width: 200px;"
                      v-model="listQuery.entity.mallOrder.orderNo">
            </el-input>
            <el-input @keyup.enter.native="handleFilter" class="filter-item input" placeholder="物流单号"
                      style="width: 200px;"
                      v-model="listQuery.entity.mallOrder.logNo">
            </el-input>
            <el-input @keyup.enter.native="handleFilter" class="filter-item input" placeholder="下单人编号"
                      style="width: 200px;"
                      v-model="listQuery.entity.user.code">
            </el-input>
            <el-input @keyup.enter.native="handleFilter" class="filter-item input" placeholder="收货人手机号"
                      style="width: 200px;"
                      v-model="listQuery.entity.mallOrder.phone">
            </el-input>
            <el-input @keyup.enter.native="handleFilter" class="filter-item input" placeholder="收货人"
                      style="width: 200px;"
                      v-model="listQuery.entity.mallOrder.name">
            </el-input>
            <el-select @change='handleFilter' class="filter-item input" clearable placeholder="是否支付"
                       style="width: 130px"
                       v-model="listQuery.entity.mallOrder.paid">
                <el-option :key="item" :label="item" :value="index" v-for="(item,index) in  paidOptions">
                </el-option>
            </el-select>
            <el-select @change='handleFilter' class="filter-item input" clearable placeholder="支付方式"
                       style="width: 130px"
                       v-model="listQuery.entity.mallOrder.payWay">
                <el-option :key="item" :label="item" :value="index" v-for="(item,index) in  payWayOptions">
                </el-option>
            </el-select>
            <el-select @change='handleFilter' class="filter-item input" clearable placeholder="订单状态"
                       style="width: 130px"
                       v-model="listQuery.entity.mallOrder.orderStatus">
                <el-option :key="item" :label="item" :value="index" v-for="(item,index) in  orderStatusOptions">
                </el-option>
            </el-select>
            <el-date-picker
                    @change='handleFilter'
                    class="filter-item input"
                    end-placeholder="订单时间结束日期"
                    range-separator="至"
                    start-placeholder="订单时间开始日期"
                    type="datetimerange"
                    v-model="listQuery.entity.mallOrder.orderTimes"
                    value-format="yyyy-MM-dd HH:mm:ss">
            </el-date-picker>

            <div style="display: inline-block">

                <el-button @click="handleFilter" class="filter-item" icon="el-icon-search" style="margin-left: 10px;"
                           type="primary"
                           v-waves>查找
                </el-button>
                <!--                <el-button @click="handleCreate" class="filter-item" icon="el-icon-edit" style="margin-left: 10px;"-->
                <!--                           type="primary" v-if="canSave">添加-->
                <!--                </el-button>-->
                <el-button :loading="downloadLoading" @click="handleDownload" class="filter-item"
                           icon="el-icon-download" type="primary"
                           v-waves>导出
                </el-button>

                <el-button  :loading="downloadLoading" style="" class="filter-item input" type="primary" v-waves
                           icon="el-icon-download"
                           @click="downSend">配货
                </el-button>

                <el-button  :loading="isLoading" style="" class="filter-item input" type="primary" v-waves
                            icon="el-icon-refresh-right"
                            @click="resetWait">恢复
                </el-button>

                <el-button  :loading="isLoading" style="" class="filter-item input" type="primary" v-waves
                           icon="el-icon-upload2"
                           @click="openFile">上传
                </el-button>

                <input style="display: none" ref="file" @change="upload" type="file">




            </div>
        </div>

        <el-table :data="list" :key='tableKey' border fit highlight-current-row
                  style="width: 100%" v-loading="listLoading">
            <el-table-column align="center" label="序号">
                <template slot-scope="scope">
                    <span>{{scope.$index+1}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="订单号" width="160">
                <template slot-scope="scope">
                    <span>{{scope.row.mallOrder.orderNo}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="下单人" width="130">
                <template slot-scope="scope">
                    <span>{{scope.row.user.name}}-{{scope.row.user.code}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="收货人">
                <template slot-scope="scope">
                    <span>{{scope.row.mallOrder.name}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="手机号" width="110">
                <template slot-scope="scope">
                    <span>{{scope.row.mallOrder.phone}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="价格">
                <template slot-scope="scope">
                    <span>{{scope.row.mallOrder.price}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="积分">
                <template slot-scope="scope">
                    <span>{{scope.row.mallOrder.point}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="实际支付">
                <template slot-scope="scope">
                    <span>{{scope.row.mallOrder.pay}}</span>
                </template>
            </el-table-column>

            <el-table-column align="center" label="物流单号" width="160">
                <template slot-scope="scope">
                    <span>{{scope.row.mallOrder.logNo}}</span>
                </template>
            </el-table-column>

            <el-table-column align="center" label="物流公司">
                <template slot-scope="scope">
                    <span>{{scope.row.mallOrder.logCompany}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="物流费">
                <template slot-scope="scope">
                    <span>{{scope.row.mallOrder.logFee}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="是否支付">
                <template slot-scope="scope">
                                                <span>

                         <el-tag :type="tagTypes[scope.row.mallOrder.paid]">     {{paidOptions[scope.row.mallOrder.paid]}}</el-tag>

                        </span>
                </template>
            </el-table-column>



            <el-table-column align="center" label="支付方式">
                <template slot-scope="scope">
                                                <span>

                         <el-tag :type="tagTypes[scope.row.mallOrder.payWay]">     {{payWayOptions[scope.row.mallOrder.payWay]}}</el-tag>

                        </span>
                </template>
            </el-table-column>

            <el-table-column align="center" label="订单状态">
                <template slot-scope="scope">
                                                <span>

                         <el-tag :type="tagTypes[scope.row.mallOrder.orderStatus]">     {{orderStatusOptions[scope.row.mallOrder.orderStatus]}}</el-tag>

                        </span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="订单时间" width="160">
                <template slot-scope="scope">
                    <span>{{parseTime(scope.row.mallOrder.orderTime)}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="支付时间" width="160">
                <template slot-scope="scope">
                    <span>{{parseTime(scope.row.mallOrder.payTime)}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" label="发货时间" width="160">
                <template slot-scope="scope">
                    <span>{{parseTime(scope.row.mallOrder.sendTime)}}</span>
                </template>
            </el-table-column>

            <el-table-column align="center" class-name="small-padding fixed-width" label="操作" width="230">
                <template slot-scope="scope">
                    <el-button @click="handleUpdate(scope)" size="mini" type="primary" v-if="canUpdate">编辑</el-button>
                    <el-button @click="handleDetail(scope)" size="mini" type="success" v-if="canUpdate">详情</el-button>
                    <el-button @click="handleDelete(scope)" size="mini" type="danger"
                               v-if="canSave">删除
                    </el-button>
                </template>
            </el-table-column>

        </el-table>

        <div class="pagination-container" style="margin-top: 20px">
            <el-pagination :current-page="listQuery.entity.mallOrder.page" :page-size="listQuery.entity.mallOrder.limit"
                           :page-sizes="[10,20,30, 50]"
                           :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange"
                           background layout="total, sizes, prev, pager, next, jumper">
            </el-pagination>
        </div>

        <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
            <el-form :model="temp" :rules="rules" label-position="left" label-width="120px" ref="dataForm"
                     style='width: 450px; margin-left:50px;'>
                <el-form-item label="价格" prop="price">
                    <el-input v-model="temp.mallOrder.price"></el-input>
                </el-form-item>
                <el-form-item label="积分" prop="point">
                    <el-input v-model="temp.mallOrder.point"></el-input>
                </el-form-item>
                <el-form-item label="实际支付" prop="pay">
                    <el-input v-model="temp.mallOrder.pay"></el-input>
                </el-form-item>
                <el-form-item label="省" prop="province">
                    <el-input v-model="temp.mallOrder.province"></el-input>
                </el-form-item>
                <el-form-item label="市" prop="city">
                    <el-input v-model="temp.mallOrder.city"></el-input>
                </el-form-item>
                <el-form-item label="县" prop="county">
                    <el-input v-model="temp.mallOrder.county"></el-input>
                </el-form-item>
                <el-form-item label="详细地址" prop="detail">
                    <el-input v-model="temp.mallOrder.detail"></el-input>
                </el-form-item>
                <el-form-item label="手机号" prop="phone">
                    <el-input v-model="temp.mallOrder.phone"></el-input>
                </el-form-item>
                <el-form-item label="收货人" prop="name">
                    <el-input v-model="temp.mallOrder.name"></el-input>
                </el-form-item>
                <el-form-item label="物流公司" prop="logCompany">
                    <el-input v-model="temp.mallOrder.logCompany"></el-input>
                </el-form-item>
                <el-form-item label="物流单号" prop="logCompany">
                    <el-input v-model="temp.mallOrder.logNo"></el-input>
                </el-form-item>
                <el-form-item label="物流费" prop="logFee">
                    <el-input v-model="temp.mallOrder.logFee"></el-input>
                </el-form-item>
                <el-form-item label="备注" prop="logFee">
                    <el-input type="textarea" v-model="temp.mallOrder.remark"></el-input>
                </el-form-item>
                <el-form-item label="是否支付" prop="status">
                    <el-select class="filter-item" placeholder="是否支付" v-model="temp.mallOrder.paid">
                        <el-option :key="item" :label="item" :value="index"
                                   v-for="(item,index) in  paidOptions">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="支付方式" prop="status">
                    <el-select class="filter-item" placeholder="支付方式" v-model="temp.mallOrder.payWay">
                        <el-option :key="item" :label="item" :value="index"
                                   v-for="(item,index) in  payWayOptions">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="订单状态" prop="status">
                    <el-select class="filter-item" placeholder="订单状态" v-model="temp.mallOrder.orderStatus">
                        <el-option :key="item" :label="item" :value="index"
                                   v-for="(item,index) in  orderStatusOptions">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="订单时间" prop="date">
                    <el-date-picker placeholder="订单时间" type="datetime"
                                    v-model="temp.mallOrder.orderTime" value-format="yyyy-MM-dd HH:mm:ss">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="支付时间" prop="date">
                    <el-date-picker placeholder="支付时间" type="datetime"
                                    v-model="temp.mallOrder.payTime" value-format="yyyy-MM-dd HH:mm:ss">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="发货时间" prop="date">
                    <el-date-picker placeholder="发货时间" type="datetime"
                                    v-model="temp.mallOrder.sendTime" value-format="yyyy-MM-dd HH:mm:ss">
                    </el-date-picker>
                </el-form-item>

            </el-form>
            <div class="dialog-footer" slot="footer">
                <el-button @click="closeDialogForm">取消</el-button>
                <el-button @click="createData" type="primary" v-if="dialogStatus=='create'">确认</el-button>
                <el-button @click="updateData" type="primary" v-else>确认</el-button>
            </div>
        </el-dialog>

        <el-dialog :visible.sync="dialogTableVisible" center title="订单详情" v-if="temp.mallOrder" width="60%">
            <div class="order-detail">
                <div class="item">
                    <div class="item-con">
                        <span class="key">订单编号</span>
                        <span class="value">{{temp.mallOrder.orderNo}}</span>
                    </div>
                </div>

              <div class="item">
                <span class="key">下单人</span>
                <span class="value">{{temp.user.name}}-{{temp.user.code}}</span>
              </div>

                <div class="item">
                    <span class="key">收货人电话</span>
                    <span class="value">{{temp.mallOrder.phone}}</span>
                </div>


              <div class="item">
                <span class="key">收货人</span>
                <span class="value">{{temp.mallOrder.name}}</span>
              </div>
              <div class="item">
                <span class="key">收货地址</span>
                <span class="value">{{temp.mallOrder.province}}{{temp.mallOrder.city}}{{temp.mallOrder.county}}{{temp.mallOrder.detail}}</span>
              </div>
                <div class="item">
                    <span class="key">订单状态</span>
                    <span class="value">{{orderStatusOptions[temp.mallOrder.orderStatus]}}</span>
                </div>


                <div class="item">
                    <span class="key">是否付款</span>
                    <span class="value">{{paidOptions[temp.mallOrder.paid]}}</span>
                </div>
                <div class="item">
                    <span class="key">付款方式</span>
                    <span class="value">{{payWayOptions[temp.mallOrder.payWay]}}</span>
                </div>
              <div class="item">
                <span class="key">订单金额</span>
                <span class="value">{{temp.mallOrder.price}}</span>
              </div>
              <div class="item">
                <span class="key">物流费用</span>
                <span class="value">{{temp.mallOrder.logFee}}</span>
              </div>
                <div class="item">
                    <span class="key">实付金额</span>
                    <span class="value">{{temp.mallOrder.pay}}</span>
                </div>

                <div class="item">
                    <span class="key">订单积分</span>
                    <span class="value">{{temp.mallOrder.point}}</span>
                </div>


                <div class="item">
                    <span class="key">物流单号</span>
                    <span class="value">{{temp.mallOrder.logNo}}</span>
                </div>
                <div class="item" >
                    <span class="key">物流公司</span>
                    <span class="value">{{temp.mallOrder.logCompany}}</span>
                </div>

                <div class="item">
                    <span class="key">下单时间</span>
                    <span class="value">{{parseTime(temp.mallOrder.orderTime)}}</span>
                </div>
                <!--                <div class="item">-->
                <!--                    <span class="key">支付时间</span>-->
                <!--                    <span class="value">{{parseTime(temp.mallOrder.payStatus)}}</span>-->
                <!--                </div>-->
                <div class="item" >
                    <span class="key">发货时间</span>
                    <span class="value"
                          v-if="temp.mallOrder.sendTime">{{parseTime(temp.mallOrder.sendTime)}}</span>
                </div>

                <div class="item">
                    <span class="key">备注</span>
                    <span class="value">{{temp.mallOrder.remark}}</span>
                </div>

            </div>
            <el-divider>订单明细</el-divider>
            <el-table
                    :data="temp.mallOrder.items"
                    border
                    show-summary
                    style="width: 100%">
                <el-table-column
                        align="center"
                        label="产品"
                        prop="name"
                        width="350">
                </el-table-column>
                <el-table-column
                        align="center"
                        label="类别"
                        width="200"
                >
                    <template slot-scope="scope">
                        {{scope.row.skuName?scope.row.skuName:'默认'}}
                    </template>
                </el-table-column>
                <el-table-column
                        align="center"
                        label="价格"
                        prop="price">
                </el-table-column>
                <el-table-column
                        align="center"
                        label="数量"
                        prop="quantity">
                </el-table-column>
                <el-table-column
                        align="center"
                        label="总额"
                        prop="totalPrice"
                       >

                </el-table-column>
            </el-table>

        </el-dialog>

    </div>
</template>
<style type="stylus" lang="stylus">
    .filter-container {
        /*padding-bottom: 20px;*/
    }

    .filter-item {
        margin-bottom: 10px;
    }

    .filter-item.input {
        /*line-height: 60px*/
        margin-right: 10px;
    }

    .order-detail
        display flex
        flex-wrap wrap
        .item
            margin-bottom 20px
            display flex
            align-items center
            justify-content flex-start
            width 50%
            .value
                margin-left 20px
</style>

<script>
    import {info,down,resetWait,downSend, upload,list, remove, save, update} from '@/api/mall_order'
    import waves from '@/directive/waves' // 水波纹指令
    import {downExcel} from '@/utils/down'
    import {parseTime} from '@/utils'


    import {mapGetters} from 'vuex'
    import {hasAuth} from '@/utils/auth'

    export default {
        name: 'test',
        directives: {
            waves
        },
        data() {
            return {
                tableKey: 0,
                list: null,
                total: null,
                isLoading:false,
                listLoading: true,
                orderTime: null
                ,
                payTime: null
                ,
                sendTime: null
                ,
                listQuery: {
                    page: 1,
                    limit: 20,
                    json: true,
                    order: 'mallOrder.paid desc,mallOrder.order_status,mallOrder.id desc',
                    entity: {
                        mallOrder: {
                            orderNo: null,
                            logNo: null,
                            payWay: null,
                            price: null
                            , point: null
                            , pay: null
                            , province: null
                            , city: null
                            , county: null
                            , detail: null
                            , phone: null
                            , name: null
                            , logCompany: null
                            , logFee: null
                            , orderTime: null,
                            orderTimes: null
                            , payTime: null,
                            payTimes: null
                            , sendTime: null,
                            sendTimes: null
                            , paid: null
                            , orderStatus: null
                        },
                        user: {
                            name: null,
                            code: null
                        }
                    },
                },
                paidOptions: ["否", "是"],
                payWayOptions: ["微信", "存储金"],
                orderStatusOptions: ["新订单", "配货中", "已发货","已取消"],
                tagTypes: ['info', '', 'warning', 'danger', 'warning'],
                temp: {
                    mallOrder:{
                        id: null,
                        payWay:null,
                        price: null,
                        point: null,
                        pay: null,
                        paid: null,
                        orderTime: null,
                        payTime: null,
                        sendTime: null,
                        orderStatus: null,
                        province: null,
                        city: null,
                        county: null,
                        detail: null,
                        phone: null,
                        name: null,
                        logCompany: null,
                        logFee: null,
                        remark:null
                    },
                    user:{

                    }
                }
                ,
                dialogFormVisible: false,
                dialogTableVisible: false,
                dialogStatus: '',
                textMap: {
                    update: '修改',
                    create: '新增'
                }
                ,
                rules:
                    {
                        price: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        point: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        pay: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        paid: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'blur'
                            }
                        ]
                        ,
                        orderTime: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        payTime: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        sendTime: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        orderStatus: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'blur'
                            }
                        ]
                        ,
                        province: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        city: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        county: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        detail: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        phone: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        name: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        logCompany: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                        ,
                        logFee: [
                            {
                                required: false,
                                message: '必填字段',
                                trigger: 'change'
                            }
                        ]
                    }
                ,
                downloadLoading: false,
                qData:
                    {
                        token: '',
                        key: ''
                    }
            }
        },
        activated() {
            this.getList()
        },
        computed: {
            ...mapGetters([
                'perms'
            ]),
            canSave() {
                return hasAuth(this.perms, 'mall:order:save')
            },
            canDelete() {
                return hasAuth(this.perms, 'mall:order:delete')
            },
            canUpdate() {
                return hasAuth(this.perms, 'mall:order:update')
            },
            canList() {
                return hasAuth(this.perms, 'mall:order:list')
            }
        },
        methods: {
            openFile(){
                this.$refs.file.click()
            },
            upload(e){
                upload(e.target.files[0]).then(res => {
                    this.$notify({
                        title: '成功',
                        message: '上传成功',
                        type: 'success',
                        duration: 2000
                    })
                    this.downloadLoading = false
                    this.getList()
                })
            },
            downSend(){
                this.downloadLoading = true
                downSend().then(res => {
                    downExcel(res)
                    this.$notify({
                        title: '成功',
                        message: '下载成功',
                        type: 'success',
                        duration: 2000
                    })
                    this.downloadLoading = false
                    this.getList()
                })
            },
            resetWait(){
                resetWait().then(res => {
                    this.$notify({
                        title: '成功',
                        message: '重置成功',
                        type: 'success',
                        duration: 2000
                    })
                    this.getList()
                })

            },
            parseTime(time) {
                if(!time)return ''
                return parseTime(time, '{y}-{m}-{d} {h}:{i}:{s}')
            },
            getList() {
                this.listLoading = true
                list(this.listQuery).then(response => {
                    this.list = response.data.list
                    this.total = response.data.total
                    this.listLoading = false
                })
            },
            handleFilter() {
                this.listQuery.entity.mallOrder.page = 1
                this.getList()
            },
            handleSizeChange(val) {
                this.listQuery.entity.mallOrder.limit = val
                this.getList()
            },
            handleCurrentChange(val) {
                this.listQuery.entity.mallOrder.page = val
                this.getList()
            },
            handleModifyStatus(row, status) {
                this.$message({
                    message: '操作成功',
                    type: 'success'
                })
                row.status = status
            },
            beforeFormShow(row) {
                this.resetTemp(row) // 更新数据
                // 存在图片

            },
            afterFormShow(row) {

            },
            beforeFormCommit() {
            },
            resetTemp(row) {

                this.temp = {}
                if (row) {
                    this.temp = Object.assign({}, row.mallOrder) // copy obj
                }

            },
            handleCreate() {
                this.beforeFormShow()
                this.resetTemp()
                this.dialogStatus = 'create'
                this.dialogFormVisible = true
                this.$nextTick(() => {
                    this.afterFormShow()
                    this.$refs['dataForm'].clearValidate()
                })
            },
            handleDelete(scope) {
                this.index = scope.$index
                // this.beforeFormShow(scope.row)
                // this.temp = Object.assign({}, row) // copy obj
                this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    // this.$message({
                    //   type: 'success',
                    //   message: '删除成功!'
                    // })
                    this.deleteData()
                }).catch(() => {
                    this.$message({
                        type: 'error',
                        message: '删除失败'
                    })
                })
            },
            createData() {
                this.$refs['dataForm'].validate((valid) => {
                        if (valid) {
                            this.beforeFormCommit()
                            save(this.temp).then(res => {
                                this.temp = res.data
                                this.list.unshift(this.temp)
                                this.closeDialogForm()
                                this.$notify({
                                    title: '成功',
                                    message: '创建成功',
                                    type: 'success',
                                    duration: 2000
                                })
                            })
                        }
                    }
                )
            },
            deleteData() {
                // const ids = [this.temp.id]
                const ids = [this.list[this.index].mallOrder.id]
                remove({ids: ids}).then(res => {
                    // 从当前队列中移除
                    this.list.splice(this.index, 1)
                    this.$notify({
                        title: '成功',
                        message: '删除成功',
                        type: 'success',
                        duration: 2000
                    })
                })
            },
            handleUpdate(scope) {
                this.index = scope.$index
                info(scope.row.mallOrder.id).then(res => {
                    this.temp = res.data
                    this.dialogStatus = 'update'
                    this.dialogFormVisible = true
                    this.$nextTick(() => {
                        this.$refs['dataForm'].clearValidate()
                    })
                })
            },
            handleDetail(scope) {
                info(scope.row.mallOrder.id).then(res => {
                    this.temp = res.data
                    this.dialogTableVisible = true
                })
            },
            updateData() {
                this.$refs['dataForm'].validate((valid) => {
                        if (valid) {
                            this.beforeFormCommit()
                            this.temp.json = true
                            update(this.temp).then((res) => {
                                this.list.splice(this.index, 1, this.temp)
                                this.closeDialogForm()
                                this.$notify({
                                    title: '成功',
                                    message: '更新成功',
                                    type: 'success',
                                    duration: 2000
                                })
                            })
                        }
                    }
                )
            },
            closeDialogForm() {
                this.dialogFormVisible = false
            },
            handleDownload() {
                this.downloadLoading = true
                down(this.listQuery).then(res => {
                    this.downloadLoading = false
                    downExcel(res)
                    this.$notify({
                        title: '成功',
                        message: '导出成功',
                        type: 'success',
                        duration: 2000
                    })
                })
            },
            formatJson(filterVal, jsonData) {
                return jsonData.map(v => filterVal.map(j => {
                        return v[j]
                    }
                ))
            },
        }
    }
</script>
